package com.qf.md.type.controller;


import com.qf.common.R;
import com.qf.entity.md.type.MdItemType;
import com.qf.md.type.param.TypeParam;
import com.qf.md.type.service.MdItemService;
import com.qf.md.type.vo.MdTypeVO;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/md/type")
public class MdItemTypeController {
    @Resource
    @Qualifier("mit")
    private MdItemService mdItemService;
    @GetMapping("/list")
    public R<List<MdTypeVO>> findTypeVO() {
        return R.ok(mdItemService.findTypeVO());
    }

    @PostMapping("/deletebyId")
    public R<String> deleteById(Long id) {
        System.out.println(id);
        mdItemService.deleteById(id);
        return R.ok("删除成功");
    }

    /**
     * 根据id查询分类的信息
     * @param id
     * @return
     */
    @GetMapping("/info")
    public R<MdItemType> info(Long id) {
        System.out.println("line:40"+id);
        return R.ok(mdItemService.typeInfo(id));
    }
    @PostMapping("/save")
    public R<String> save(@RequestBody TypeParam typeParam) {
        System.out.println(typeParam);
        mdItemService.save(typeParam);
        return R.ok("保存成功");
    }

}

